home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
public
/
bit
/
src
/
mpeg
/
gldisplay.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
3KB
|
153 lines
/********************************************************************
*. This file is part of BIT shareware package.
*
* Copyright(c) 1993, 1994 by T.C. Zhao.
* All rights reserved.
*.
*
*******************************************************************/
#include "video.h"
#include "gl/gl.h"
#include "gl/device.h"
static long winh = 290, winw = 330;
static long winid = -1;
static float zoom = 2.0;
static int w, h;
extern int noDisplayFlag;
extern int run_in_background;
void
set_maginification(float f)
{
zoom = f;
}
static void
resize_win(void)
{
long xo, yo;
winset(winid);
getorigin(&xo, &yo);
winw = w * zoom;
winh = h * zoom;
winposition(xo, xo + winw - 1, yo, yo + winh - 1);
}
static void
remap_win(void)
{
winset(winid);
reshapeviewport();
getsize(&winw, &winh);
cpack(0);
clear();
reshapeviewport();
ortho2(-0.5, winw - 0.5, -0.5, winh - 0.5);
}
static void
finish_it(void)
{
winclose(winid);
gexit();
exit(1);
}
static void
check_events(void)
{
long dev;
short val;
static char *spop = "MPEGcntl%t|1x1|2x2|3x3|Quit %x10";
static long menu = -1;
int p;
if (!qtest())
return;
if (menu < 0)
menu = defpup(spop);
switch ((dev = qread(&val)))
{
case MENUBUTTON:
if (val)
{
switch ((p = dopup(menu)))
{
case 1:
case 2:
case 3:
zoom = p;
resize_win();
remap_win();
rectzoom((float) p, (float) p);
break;
case 10:
finish_it();
break;
}
}
break;
case REDRAW:
if (val == winid)
remap_win();
break;
case ESCKEY:
if (val)
finish_it();
case SPACEKEY:
if (val)
{
while (qread(&val) != SPACEKEY || !val)
;
}
break;
}
}
void
glDisplay(VidStream * vid_stream)
{
int x, y;
if (noDisplayFlag)
return;
w = vid_stream->mb_width * 16;
h = vid_stream->mb_height * 16;
if (winid <= 0)
{
winw = zoom * w;
winh = zoom * h;
if (!run_in_background)
foreground();
prefsize(winw, winh);
winid = winopen("BIT: sgimpeg");
RGBmode();
gconfig();
remap_win();
rectzoom(zoom, zoom);
qdevice(ESCKEY);
qdevice(SPACEKEY);
qdevice(MENUBUTTON);
}
check_events();
/* center the image both horizontally and vertically in window */
x = (winw - w * zoom) / 2;
y = (winh - h * zoom) / 2;
lrectwrite(x, y, w + x - 1, h + y - 1,
(unsigned long *) vid_stream->current->display);
}